package org.pixelami.twisted.spread.jelly
{
	import flash.utils.Dictionary;
	
	public class Jelly
	{
		private static var _uid:uint = 0;
		
		public static function id(obj:Object):uint
		{
			return _uid++
		}
		
		
		public static function jelly(object:Object, taster:Object, persistentStore:Object=null, invoker:Object=null):Object
		{ 
			if(!taster) taster = new DummySecurityOptions();
			
			return new _Jellier(taster, persistentStore, invoker).jelly(object)
		}
		
		public static function unjelly(sexp:Array, taster:Object, persistentLoad:Object=null, invoker:Object=null):Object
		{
			if(!taster) taster = new DummySecurityOptions();
			
			return new _Unjellier(taster, persistentLoad, invoker).unjellyFull(sexp)
		}
		
		public static var unjellyableRegistry:Dictionary = new Dictionary();
		
		public static var unjellyableFactoryRegistry:Dictionary = new Dictionary();
		
		public static function setUnjellyableForClass(classname:Object, unjellyable:Object):void
		{
			/*
		    """
		    Set which local class will represent a remote type.
		
		    If you have written a Copyable class that you expect your client to be
		    receiving, write a local "copy" class to represent it, then call::
		
		        jellier.setUnjellyableForClass('module.package.Class', MyJellier).
		
		    Call this at the module level immediately after its class
		    definition. MyCopier should be a subclass of RemoteCopy.
		
		    The classname may be a special tag returned by
		    'Copyable.getTypeToCopyFor' rather than an actual classname.
		
		    This call is also for cached classes, since there will be no
		    overlap.  The rules are the same.
		    """
			*/
		    //global unjellyableRegistry
		    //classname = _maybeClass(classname)
		    unjellyableRegistry[classname] = unjellyable;
		    //globalSecurity.allowTypes(classname)
		}
		
		/*
		//WTF !!
		
		public static function _maybeClass(classnamep)
		{
		    try
		    {
		        object;
		    }
		    catch(e: NameError)
		    {
		        isObject = 0;
		    }
		    else
		    {
		        isObject = isinstance(classnamep, type);
		    }
		    if (isinstance(classnamep, ClassType) or isObject)
		    {
		        return qual(classnamep);
		    }
		    return classnamep;
		}
		*/

		
		public function Jelly()
		{
		}

	}
	
	
	
}

